package cn.iotab.iotkit.transport.api.driver;

import cn.iotab.iotkit.transport.api.common.message.msg.up.SessionInfo;
import lombok.Data;

/**
 * Session信息
 */
@Data
public class DriverSession {

    private final SessionInfo sessionInfo;

    private final SessionMsgListener listener;

    //最近一次active时间
    private volatile long lastActivityTime;
    //上一次上报时间
    private volatile long lastReportedActivityTime;

    //是否定义设备消息topic
    private volatile boolean subscribedMessageTopic;
    //是否订阅响应topic
    private volatile boolean subscribedReplyTopic;

    public DriverSession(SessionInfo sessionInfo, SessionMsgListener listener) {
        this.sessionInfo = sessionInfo;
        this.listener = listener;
        this.lastActivityTime = System.currentTimeMillis();
    }

    public SessionInfo getSessionInfo(){
        return sessionInfo;
    }

    public void updateLastActivityTime() {
        this.lastActivityTime = System.currentTimeMillis();
    }
}
